<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ws Client</title>
</head>
<body>
<h1>WebSocket</h1>
<div id="chatroot" style="width: 400px;height: 300px;overflow: auto;border: 1px solid blue"></div>
<input type="text" name="sayinput" id="sayinput" value="">
<input type="button" name="send" id="sendbutton" value="发送">
<script type="text/javascript" src="WsClient.js"></script>
<script type="text/javascript">
    var sayinput = document.getElementById('sayinput');
    function send(){
        ws.send(sayinput.value);
        sayinput.value = '';
    }
    document.onkeyup = function (event) {
        if(event.keycode===13){
            send();
        }
    }
    var sendbutton = document.getElementById('sendbutton');
    sendbutton.onclick = function () {
        send();
    }
</script>
</body>
</html>